$(function(){
	dictionaryStart("model","104001");
	dictionaryStart("productionfactory","104002");
	//xlStart();
	
	var reqcolumn = [
	    "devicename"/*,             
		"equipmentowner",
		"assetnumber",
		"ratedcapacity",
		"groundingresistance"*/
	]
	addrequired(reqcolumn);
});

function add(){
	if(!validateForm()){
		return;
	}
	var list=$("#form").serialize();
	$.ajax({
		url : basePath+"user/zyzsdlq/add",
		data : {data : list},
		type : "post",
		success : function(data){
			alert(data.msgDesc);
			if(data.opResult=="0"){
				location.href=basePath+"user/z/zyzsdlqlist.jsp?deviceid="+deviceid+"&t="+new Date().getTime();
			}
		}
	});
}

function edite(){
	if(!validateForm()){
		return;
	}
	var list=$("#form").serialize();
	$.ajax({
		url : basePath+"user/zyzsdlq/edite",
		data : {data : list},
		type : "post",
		success : function(data){
			alert(data.msgDesc);
			if(data.opResult=="0"){
				location.href=basePath+"user/z/zyzsdlqlist.jsp?deviceid="+deviceid+"&t="+new Date().getTime();
			}
		}
	});
}

function setDefault(elementId,data){
	$('#'+elementId).val(data);
}

function gettotalcapacity(){
	var singlecapacity=$('#singlecapacity').val();
	if(singlecapacity==null||singlecapacity==""){
		alert("请输入单只容量");
		return;
	}
	var thenumber=$("#thenumber").val();
	$("#groupcapacity").val(thenumber*parseFloat(singlecapacity));
	
}

function validateForm(){
	if($("#devicename").val()==""){
		alert("设备名称为空");
		return false;
	}
	/*if($("input[name='localcity']").val()==""){
		alert("所属地市为空");
		return false;
	}
	if($("input[name='operationunit']").val()==""){
		alert("运维单位为空");
		return false;
	}
	if($("input[name='maintenanceteam']").val()==""){
		alert("维护班组为空");
		return false;
	}
	if($("input[name='commissioningdate']").val()==""){
		alert("投运日期为空");
		return false;
	}
	if($("input[name='equipmentowner']").val()==""){
		alert("设备主人为空");
		return false;
	}
	if($("input[name='assetnumber']").val()==""){
		alert("资产编号为空");
		return false;
	}
	if($("input[name='commissioningdate']").val()==""){
		alert("投运日期为空");
		return false;
	}
	if(!isVoltage($("input[name='ratedvoltage']").val())){
		alert("额定电压不正确，如220v或1kv");
		return false;
	}
	if(!isNum($("input[name='ratedcapacity']").val())){
		alert("额定电流只能为数字");
		return false;
	}
	if(!validateNum($("input[name='ratedshortcircuitcur']").val())){
		alert("额定短路开断电流只能为数字");
		return false;
	}
	if(!validateInt($("input[name='ratedshortcircuitnum']").val())){
		alert("额定短路电流开断次数只能为整数");
		return false;
	}
	if(!validateNum($("input[name='dropawaycurrent']").val())){
		alert("过流脱扣器额定脱扣电流(低压)只能为数字");
		return false;
	}
	if(!isNum($("input[name='groundingresistance']").val())){
		alert("接地电阻只能为数字");
		return false;
	}*/
	return true;
}